package com.itheima.Job4;

import java.util.HashSet;
import java.util.Iterator;

public class test {
    public static void main(String[] args) {
        HashSet<String> names = new HashSet<>();
        names.add("刘备");
        names.add("关羽");
        names.add("张飞");
        names.add("刘备");
        names.add("张飞");
        System.out.println("集合大小"+names.size());
        //迭代器遍历
        Iterator iterator = names.iterator();
        while (iterator.hasNext()) {
            Object next =  iterator.next();
            System.out.println(next);
        }
        System.out.println("==========");
        //增强for
        for (String name : names) {
            System.out.println(name);
        }
    }
}
